//
// Created by Felix on 24-4-25.
//

#ifndef GAZE_USERSERVICE_HPP
#define GAZE_USERSERVICE_HPP

#include "oatpp/web/protocol/http/Http.hpp"
#include "oatpp/core/macro/component.hpp"

#include "common.hpp"

#include "db/UserDb.hpp"
#include "db/LoginLogDb.hpp"
#include "dto/DTOs.hpp"
#include "dto/UserResponseDto.hpp"
#include "dto/UserCreateDto.hpp"
#include "dto/UserUpdateDetailsDto.hpp"
#include "dto/UserUpdateStatusDto.hpp"
#include "dto/UserUpdatePasswordDto.hpp"
#include "dto/UserServiceGetAllUsersQueryDto.hpp"

class UserService {
private:
    typedef oatpp::web::protocol::http::Status Status;
    OATPP_COMPONENT(std::shared_ptr<UserDb>, iUserDatabase);
public:
    oatpp::Object<UserResponseDto> createUser(
            const oatpp::Object<UserCreateDto> &dto
    ); // Create user
    oatpp::Object<UserResponseDto> updateUserDetails(
            const oatpp::Object<UserUpdateDetailsDto> &dto
    ); // Update user details
    oatpp::Object<UserResponseDto> updateUserStatus(
            const oatpp::Object<UserUpdateStatusDto> &dto
    ); // Update user status
    oatpp::Object<UserResponseDto> updateUserPassword(
            const oatpp::Object<UserUpdatePasswordDto> &dto
    ); // Update user password
    oatpp::Object<PageResponseDto<oatpp::Object<UserResponseDto> > > getAllUsers(
            const oatpp::Int32 &page, const oatpp::Int32 &pageSize,
            const oatpp::Object<UserServiceGetAllUsersQueryDto> &queryDto
    ); // Get all users
    oatpp::Object<UserResponseDto> getUserById(
            const oatpp::Int32 &userId
    ); // Get user by userId
    oatpp::Object<UserResponseDto> getUserByUsername(
            const oatpp::String &username
    );// Get user by username
    oatpp::Object<UserResponseDto> getUserByUsernameFilterOutUserId(
            const oatpp::String &username,
            const oatpp::Int32 &userId
    ); // Get user by username filter out userId
private:
    static oatpp::Object<UserResponseDto> userResponseDtoFromModel(const oatpp::Object<UserModel> &model); //
    static oatpp::Object<UserModel> userModelFromCreateDto(const oatpp::Object<UserCreateDto> &dto); //
    static oatpp::Object<UserModel> userModelFromUpdateDetailsDto(const oatpp::Object<UserUpdateDetailsDto> &dto); //
    static oatpp::Object<UserModel> userModelFromUpdateStatusDto(const oatpp::Object<UserUpdateStatusDto> &dto); //
    static oatpp::Object<UserModel> userModelFromUpdatePasswordDto(const oatpp::Object<UserUpdatePasswordDto> &dto);//
};

#endif //GAZE_USERSERVICE_HPP
